<%-- ExMobi JSP文件，注释和取消快捷键统一为Ctrl+/ 多行注释为Ctrl+Shift+/ --%>
<%@ page language="java" import="java.util.*,sun.net.ftp.*,java.net.*"
 contentType="application/text; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/client/adapt.jsp"%>
<%@ include file="/client/adapt_extend.jsp"%>
<%@ include file="properties.jsp" %>
<%
	JSONObject json = new JSONObject();
    String filepath = aa.req.getAttachAddr("file");
    String filename = aa.req.getAttachName("file");
    
    String uploadpath = aa.req.getParameter("path");
    if(uploadpath.length()>0){
    	uploadpath = aa.common.deBase64(uploadpath);
    }else{
    	//uploadpath="/";
    	uploadpath = "/upload/";
    }
    
	FtpClient ftp = FtpClient.create();
	try{
	    //连接ftp
	    ftp.connect(new InetSocketAddress(_ftp_ip,_ftp_port));
	    ftp.login(_ftp_userid, _ftp_pwd.toCharArray());
		ftp.setBinaryType();
		byte[] bs =aa.common.readBinaryFile(filepath);
		InputStream is = new ByteArrayInputStream(bs);
		ftp.putFile(uploadpath+filename, is);
	}catch(Exception e){
		  String msg  = "FTP服务通讯失败！";
		  if(e instanceof java.io.FileNotFoundException){
			  msg = "文件不存在！";
		  }
		  System.out.println(msg);
		  System.out.println(e);
		  out.print(msg+" 错误信息："+e);
	}finally{
		ftp.close();
	}
	System.out.println("上传成功！");
	out.print("上传成功！");
%>
